package com.kantboot.business.gc.controller;

import com.kantboot.business.gc.domain.dto.BusGcTypeI18nDTO;
import com.kantboot.business.gc.domain.dto.BusGcTypeI18nSaveDTO;
import com.kantboot.business.gc.domain.entity.BusGcType;
import com.kantboot.business.gc.service.IBusGcTypeI18nService;
import com.kantboot.business.gc.service.IBusGcTypeService;
import com.kantboot.util.common.result.RestResult;
import com.kantboot.util.core.param.PageParam;
import com.kantboot.util.core.result.PageResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/business/gc/type")
public class BusGcTypeController {

    @Resource
    private IBusGcTypeService service;

    @Resource
    private IBusGcTypeI18nService i18nService;

    /**
     * 获取所有类型
     * @return 所有类型
     */
    @RequestMapping("/getAll")
    public RestResult<List<BusGcType>> getAll() {
        return RestResult.success(service.getAll(),"getSuccess","获取成功");
    }

    /**
     * 增加语言类型
     */
    @RequestMapping("/addLanguage")
    public RestResult addLanguage(@RequestBody BusGcTypeI18nSaveDTO saveDTO) {
        i18nService.addLanguage(saveDTO);
        return RestResult.success("addSuccess","添加成功");
    }

    /**
     * 批量删除语言类型
     */
    @RequestMapping("/deleteLanguage")
    public RestResult deleteLanguage(@RequestBody List<BusGcTypeI18nSaveDTO> busGcTypeI18nSaveDTOList) {
        i18nService.deleteLanguage(busGcTypeI18nSaveDTOList);
        return RestResult.success("deleteSuccess","删除成功");
    }

    /**
     * 获取不同类别id的语言列表
     */
    @RequestMapping("/getLanguageList")
    public RestResult<PageResult> getLanguageListByTypeId(@RequestBody PageParam<BusGcTypeI18nDTO> param) {
        return RestResult.success(i18nService.getLanguageListByTypeId(param), "getSuccess", "获取成功");
    }

}
